<template>
  <div>
    <city-header></city-header>
    <city-search :cities=cities></city-search>
    <city-list :cities=cities :hotCities=hotCities :letter=letter></city-list>
    <city-alphabet :cities=cities @change="handleLetterChange"></city-alphabet>
  </div>
</template>

<script>
import axios from 'axios'
import CityHeader from './components/Header'
import CitySearch from './components/Search'
import CityList from './components/List'
import CityAlphabet from './components/Alphabet'
export default {
  name: 'City',
  data () {
    return {
      hotCities: [],
      cities: null,
      letter: ''
    }
  },
  components: {
    CityHeader,
    CitySearch,
    CityList,
    CityAlphabet
  },
  mounted () {
    let that = this
    axios.get('/api/city.json', {})
      .then(res => {
        console.log(res)
        if (res.status === 200) {
          let result = res.data.data
          that.hotCities = result.hotCities
          that.cities = result.cities
        } else {

        }
      }).catch(error => {
        console.log(error)
      })
  },
  methods: {
    handleLetterChange (letter) {
      this.letter = letter
    }
  }
}
</script>

<style lang="stylus" scoped>

</style>
